<template>
	<view class="finance">
		<view class="title">
			<text class="ys-4">账号</text>
			<text class="ys-3">数量</text>
			<text class="ys-2">时间</text>
			<text class="ys-2 text-right">备注</text>
		</view>
		<view class="list">
			<view class="list-item" v-for="(item,index) in financeList" :key="item.id">
				<text class="ys-4">{{item.reward_type}}</text>
				<text class="ys-3">{{item.num}}</text>
				<text class="ys-2">{{item.create_time}}</text>
				<text class="ys-3 text-right">{{item.remarks}}</text>
			</view>
			<view class="no-list" v-if="financeList.length==0">
				- 暂无数据 -
			</view>
		</view>
	</view>
</template>

<script>
	import {
		finance
	} from "@/api/api.js"
	export default {
		data() {
			return {
				financeList: [],
				last_page: 1,
				page: 1
			}
		},
		onLoad() {
			this.finance()
		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page++
				this.finance()
			}
		},
		methods: {
			finance() {
				finance().then(res => {
					if (res.code == 0) {
						this.financeList = res.data.data
						this.last_page = res.data.last_page
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.finance {
		.title {
			padding: 12px 5%;
			display: flex;
			font-weight: bold;
			position: sticky;
			top: 44px;
			background: #fff;
			box-shadow: 0 1px 5px #eee;
		}

		.ys-4 {
			width: 20%;
		}

		.ys-2 {
			width: 30%;
			text-align: center;
		}

		.ys-3 {
			width: 25%;
			text-align: center;
		}

		.text-right {
			text-align: right;
		}

		.list {
			margin-top: 5px;
			padding: 0 5%;
			background-color: #FFFFFF;

			.list-item {
				display: flex;
				font-size: 12px;
				padding: 20rpx 0;
				border-bottom: 1px solid #efefef;
			}
		}
	}
</style>